<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib uri="/sinopac-fn" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>TOKEN同步管理</title>
		<link rel="stylesheet" href="${fn:url('/form/CSS/tabs.css')}">
		<script type="text/javascript" src="${fn:url('/js/jQuery/jquery-1.8.2.min.js')}"></script>
		<script type="text/javascript" src="${fn:url('/js/jQuery/jquery_DOMWindow.js')}"></script>
		<script type="text/javascript" src="${fn:url('/js/tools/formUtil.js')}"></script>
		<script>
			$(document).ready(function(){
				//檢查token同步 textfield是否為空值
				
				//同步作業成功失敗的popup視窗
				if($('#errorMessage_a').val() !="" && $('#errorMessage_a').val() != null){
					if($('#errorMessage_a').val() =="成功"){
						$.openDOMWindow({ 
					    	windowSourceID: '.tSresultDiv',
					        height:120,  
					        width:400, 
					        overlay:1, 
					        overlayColor: '#A9A9A9',
					        windowPadding:20,
					        modal:1,
					        borderColor:'steelblue',
					        borderSize:'2', 
					        positionLeft:120, 
					        positionTop:-150,
					    }); 
					}else{
						$.openDOMWindow({ 
					    	windowSourceID: '.tSresultDiv',
					        height:130,  
					        width:400, 
					        overlay:1, 
					        overlayColor: '#A9A9A9',
					        windowPadding:20,
					        modal:1,
					        borderColor:'steelblue',
					        borderSize:'2', 
					        positionLeft:120, 
					        positionTop:-150,
					    }); 
					}
				}
				//同步作業成功失敗的popup視窗的確定btn，導回主畫面。
				$('#tSresult_form input[name=resultOKbtn]').click(function(){
					var f = $('#tSresult_form');
					f.prop('action','${fn:url('/Index/chkCustId.action')}');
					f.submit();
				});
				
				//token同步的確定btn
				$('#token_sync_form input[name=synConf]').click(function(){
					if($('#synSerCode_a').val() == "" && $('#synVerifCode_a').val() == ""){
						alert("同步序號及同步驗證碼不可為空值");
						$('#synSerCode_a').focus();
					}else if($('#synSerCode_a').val() == ""){
						alert("同步序號不可為空值");	
						$('#synSerCode_a').focus();
					}else if($('#synVerifCode_a').val() == ""){
						alert("同步驗證碼不可為空值");	
						$('#synVerifCode_a').focus();
					}else{
						var s = $('#token_sync_form');
						s.prop('action','${fn:url('/TokenSynchronous/tokenSyn.action')}');
						s.submit();
					}
				});
				
				
				//token同步的取消btn，導回主畫面。
				$('#token_sync_form input[name=cancel]').click(function(){
					var s = $('#token_sync_form');
					s.prop('action','${fn:url('/Index/chkCustId.action')}');
					s.submit();
				});
				
			});
		</script>
	</head>
	<body>
		<%@ include file="/form/include/title.jsp" %>
		<div id="tSresult" class="tSresultDiv" style="display: none;" align="center">
			<form id="tSresult_form">
				<table width="400" align="center">
					<tr>
						<td><s:label value="TOKEN ESN " theme="simple"/></td>
						<td><s:property value="token_esn"/></td>
						<td><s:label value="同步作業" theme="simple"/></td>
						<td><font color="red"><s:property value="errorMessage"/></font></td>
						<s:hidden id="errorMessage_a" name="errorMessage"/>
					</tr>
					<s:if test="errorMessage =='失敗'">
						<tr>
							<td><s:label value="失敗代碼：" theme="simple"/></td>
							<td><s:property value="return_code"/><s:label value="　" theme="simple"/><s:property value="return_code_ch"/></td>
						</tr>
						<tr height="50"/>
						<tr>
							<td align="center" colspan="3"><input name="resultOKbtn" type="button" value="確定" width="200"/></td>
						</tr>
					</s:if>
					<s:else>
						<tr height="50"/>
						<tr>
							<td align="center" colspan="3"><input name="resultOKbtn" type="button" value="確定" width="200"/></td>
						</tr>
					</s:else>
				</table>
			</form>
		</div>
		<div align="center">
			<fieldset style="width: 25%">
				<s:form id="token_sync_form">		
					<table align="center">
						<tr align="left">
							<td align="left">
								<s:label value="請輸入TOKEN-ESN為" theme="simple"/>
								<font color="red"><s:property value="token_esn"/></font>
							</td>
						</tr>
						<tr>
							<td><s:label value="所產生之" theme="simple"/></td>
						</tr>
						<tr>
							<td align="left"><s:label value="同步驗證碼　" theme="simple"/><input type="text" id="synVerifCode_a" name="synVerifCode" maxlength="16" theme="simple"/></td>
						</tr>
						<tr>
							<td align="left"><s:label value="同步序號　　" theme="simple"/><input type="text" id="synSerCode_a" name="synSerCode" maxlength="4" theme="simple"/></td>
						</tr>
						<tr>
							<td align="left"><s:label value="進行同步作業" theme="simple"/></td>
						</tr>
						<tr height="10"></tr>
						<tr>
							<td colspan="3" align="center"><input name="synConf" type="button" value="確定" align="right"/><input name="cancel" type="button"  value="取消" align="left"/></td>			
						</tr>	
					</table>
				</s:form>
			</fieldset>
		</div>
	</body>
</html>